Ext.namespace("Ext.ux.plugins");
Ext.ux.plugins.PageComboResizer = Ext.extend(Object, {
	pageSizes :null,
	prefixText : "Records Per Page",
	postfixText : "",
	constructor : function(a) {
		Ext.apply(this, a);
		Ext.ux.plugins.PageComboResizer.superclass.constructor.call(this, a);
	},
	init : function(b) {
		var isShowTwoHunder=b.isShowTwoHunder;
		var isShowPicHunder=b.isShowPicHunder;
		if(isShowTwoHunder){
			this.pageSizes=[25,50,75,100,200]
		}else if(isShowPicHunder){
			this.pageSizes=[100,200]
		}else{
			this.pageSizes=[25,50,75,100]
		}
		var d = this.pageSizes;
		var c = new Ext.form.ComboBox({
			typeAhead : true,
			triggerAction : "all",
			lazyRender : true,
			mode : "local",
			width : 45,
			store : d,
			listeners : {
				select : function(k, g, e) {
					b.pageSize = d[e];
					var j = 0;
					var f = b.findParentBy(function(i, l) {
						return (i instanceof Ext.grid.GridPanel) ? true : false;
					});
					var h = f.getSelectionModel();
					if (undefined != h && h.hasSelection()) {
						if (h instanceof Ext.grid.RowSelectionModel) {
							j = f.store.indexOf(h.getSelected());
						} else {
							if (h instanceof Ext.grid.CellSelectionModel) {
								j = h.getSelectedCell()[0];
							}
						}
					}
					j += b.cursor;
					b.doLoad(Math.floor(j / b.pageSize) * b.pageSize);
				}
			}
		});
		Ext.iterate(this.pageSizes, function(e) {
			if (e == b.pageSize) {
				c.setValue(e);
				return;
			}
		});
		var a = b.items.indexOf(b.refresh);
		b.insert(++a, "-");
		b.insert(++a, this.prefixText);
		b.insert(++a, c);
		b.insert(++a, this.postfixText);
		b.on({
			beforedestroy : function() {
				c.destroy();
			}
		});
	}
});


